import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '父id',
    align: 'center',
    dataIndex: 'parentId',
  },
  {
    title: '层级数据（默认根据用户添加展示层级） ',
    align: 'center',
    dataIndex: 'type',
  },
  {
    title: '层级名称',
    align: 'center',
    dataIndex: 'courseName',
  },
  {
    title: '层级描述',
    align: 'center',
    dataIndex: 'courseDescribe',
  },
  {
    title: '排序',
    align: 'center',
    dataIndex: 'sortOrder',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [];
//表单数据
export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: 'id',
    component: 'Input',
    show: false,
  },
  {
    field: 'parentId',
    label: 'parentId',
    component: 'Input',
    show: false,
    defaultValue: '0',
  },
  {
    label: '课程标题',
    field: 'courseName',
    component: 'Input',
    required: true,
    componentProps: {
      placeholder: '请填写',
    },
    dynamicRules() {
      return [
        {
          validator: (_, value) => {
            return new Promise<void>((resolve, reject) => {
              if (value.length > 100) {
                reject('最长100个字符');
              }
              resolve();
            });
          },
        },
      ];
    },
  },
  {
    label: '课程目标',
    field: 'courseDescribe',
    component: 'Input',
    required: true,
    componentProps: {
      placeholder: '请填写',
    },
  },

  {
    field: 'courseContent',
    label: '课程介绍',
    required: true,
    component: 'Input',
    render: render.renderTinymce,
  },

  {
    field: 'annex',
    component: 'JImageUpload',
    label: '课程封面',
    // suffix: '支持.jpg .jepg.png格式 图片大小为344*200px',

    componentProps: {
      text: '上传封面',
      tip: true,
    },
  },
];

// 高级查询数据
export const superQuerySchema = {
  parentId: { title: '父id', order: 0, view: 'text', type: 'string' },
  type: { title: '层级数据（默认根据用户添加展示层级） ', order: 1, view: 'number', type: 'number' },
  courseName: { title: '层级名称', order: 2, view: 'text', type: 'string' },
  courseDescribe: { title: '层级描述', order: 3, view: 'textarea', type: 'string' },
  sortOrder: { title: '排序', order: 4, view: 'number', type: 'number' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
/* export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
} */
